#ifndef QXGAME_RENDERSHAPE_H
#define QXGAME_RENDERSHAPE_H

#include "GameVector.h"
#include "GameShape.h"
#include "SDL2_gfxPrimitives.h"

class RenderShape {
public:
    static void RendererEnemyHp(SDL_Renderer *renderer, const GameVector &position,
                                const GameShape &shape, double hp, double maxHp)
    {
        static SDL_Rect rect;
        static SDL_Point point;
        const int offsetY = 2;
        GameVector sizeHpBar = {std::max(shape.w, shape.h), 10};
        SDL_Color colorBorder = {116, 185, 124, 255};
        SDL_Color colorContent = {255, 0, 0, 255};

        rect.x = (int) (position.x - sizeHpBar.x / 2);
        rect.y = (int) (position.y - shape.h / 2 - sizeHpBar.y - offsetY);
        rect.w = (int) (sizeHpBar.x * (hp / maxHp));
        rect.h = (int) sizeHpBar.y;
        SDL_SetRenderDrawColor(renderer, colorContent.r, colorContent.g, colorContent.b, colorContent.a);
        SDL_RenderFillRect(renderer, &rect);

        rect.w = (int) sizeHpBar.x;
        SDL_SetRenderDrawColor(renderer, colorBorder.r, colorBorder.g, colorBorder.b, colorBorder.a);
        SDL_RenderDrawRect(renderer, &rect);
    }

    static void RendererHp(SDL_Renderer *renderer, const GameVector &position, double hp, double maxHp,
                           const SDL_Color &colorBackground, const SDL_Color &colorForeground)
    {
        static SDL_Rect rectDst;
        static const int width = 250;
        static const int height = 30;
        static const int widthBorderBar = 4;
        roundedBoxRGBA(renderer, position.x, position.y, position.x + width, position.y + height, 4,
                       colorBackground.r, colorBackground.g, colorBackground.b, colorBackground.a);

        double process = hp / maxHp;
        roundedBoxRGBA(renderer, position.x + widthBorderBar, position.y + widthBorderBar,
                       position.x + widthBorderBar + (width - 2 * widthBorderBar) * process,
                       position.y + height - widthBorderBar, 2,
                       colorForeground.r, colorForeground.g, colorForeground.b, colorForeground.a);
    }
};


#endif //QXGAME_RENDERSHAPE_H
